#include "AppModel.h"
#include "JsonConfigurator.h"

#include "CommonType.h"

#include <QObject>

#define CURRENT_VERSION	"1.1.1.210719"

QString CAppModel::Version_ = CURRENT_VERSION;
CAppModel* CAppModel::Instance_ = new CAppModel;
CAppModel* CAppModel::Instance()
{
	return Instance_;
}

int32_t CAppModel::LoadAppConfiguration()
{
	zl::AppConfig config;

    config.cabinet.name = "SN Write Tool";
    config.cabinet.title = QObject::tr("Tool");
    config.cabinet.cabinet_no = "0";

	int32_t ret = zl::CJsonConfigurator::Load(config);
	if (ret == zl::EResult_Success)
	{
		config_ = config;
	}

	return ret;
}

int32_t CAppModel::SaveAppConfiguration()
{
	auto ret = zl::CJsonConfigurator::Save(config_);
	return ret;
}
